var storage = window.localStorage;
var processId = storage["processId"];
storage.clear();
var vm = new Vue({
    el: '#check',
    data: {
        processId: {

        },
        processInfo:{

        },
        formdata:{

        },
        showData: false,
        arrenum:{},
        enumdata:{

        }
    },
    methods: {
        //获取审核数据
        getProcessInfo: function () {
            vm.showData = true;
            var url = "/workflow/actTask/getTaskForm?taskId="+processId;
            $.ajax({
                type: "POST",
                url: baseURL + url,
                contentType: "application/json",
                success: function (r) {
                    console.info(r);
                    if (r.code == 0) {
                        vm.processInfo = r.taskFormData;
                        vm.enumdata=r;
                        vm.processInfo.formProperties.forEach(function(val,index,arr){
                            if(val.type.name=='enum') {
                                var datajson= val.id;
                                var data=vm.enumdata[datajson];
                                var myArray=new Array();
                                var i=0;
                                for(var name in data){//遍历对象属性名
                                    var  obj={};
                                    obj.name=name;
                                    obj.value=data[name];
                                    myArray[i]=obj;
                                    i++;
                                }
                                val.list=myArray;
                            }
                        });
                    } else {
                        alert(r.errorMessage);
                    }
                }
            });
        },
        startprocess: function (event) {
            vm.processInfo.formProperties.forEach(function(val,index,arr){
                vm.formdata[val.name]= $('#'+val.name).val();
            });
            vm.formdata["taskId"]=processId;
            var url = "/workflow/actTask/complete";
            $.ajax({
                type: "POST",
                url: baseURL + url,
                contentType: "application/x-www-form-urlencoded",
                data:vm.formdata,
                success: function (r) {
                    console.info(r);
                    if (r.code == 0) {
                        window.location.href = "backlogprocess.html";
                    } else {
                        alert(r.errorMessage);
                    }
                }
            });
        },
        goBack: function () {
            window.location.href = "backlogprocess.html";
        },
        showInfo: function (id, key) {
            //显示选项图片
            $("#" + id + "_" + key + "_img_show").show();
            //显示选项文字
            $("#" + id + "_" + key + "_text_show").show();
            //显示下级选项
            $("#" + id + "_" + key).show();
        }
    }
});
$(function () {
    vm.getProcessInfo();
});
Vue.component('lower-option', {
    template: '#lowerOption',
    props: {item: {}, option: {}}
});